// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import vueRouter from 'vue-router'
import routes from '@/router'
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
import './style/iconfont/iconfont.css';
import store from './store';
import $ from 'jquery';
import axios from 'axios';
import Mixin from '@/mixins';


// import VueCookies from 'vue-cookies';

Vue.config.productionTip = false;

// Vue.use(VueCookies)
Vue.use(vueRouter)
Vue.use(ElementUI)
Vue.mixin(Mixin);
const router = new vueRouter({
  // mode:"history",
  routes,
});
Vue.$http = Vue.prototype.$http = axios.create({
  // baseURL: 'http://api.kyhddsp.com',
  baseURL: 'http://api.i6bktq.cn:83',
  withCredentials: true,// `withCredentials` 表示跨域请求时是否需要使用凭证
  timeout: 300000
});

Vue.prototype.$http.interceptors.response.use(function (response) {
  // 对响应数据做点什么
  // console.log(response.status);
  return response;
}, function (error) {
  if (error.response) {
      if (error.response.status == 403) {
          router.push({path: '/'});
      }
  }
  return Promise.reject(error);
});

router.beforeEach((to, from, next) => {
  if(to.meta.hasScroll!=undefined){
    store.state.wraHeight = 'calc(100vh - 116px)';
  }else{
    store.state.wraHeight = '100%';
  }
  next();
})
/* eslint-disable no-new */
new Vue({
  router,
  store,
  render:h=>h(App)
}).$mount('#app')
